﻿<%@ page language="java" import="com.newcrm.config.Const,com.newcrm.util.Util,com.newcrm.bean.*,java.util.List,java.util.Map" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
  User user = (User) session.getAttribute("user");
  Map<Integer, CompanyInfo> companys = (Map<Integer, CompanyInfo>) application.getAttribute(Const.APPLICATION_COMPANYS);
  CompanyInfo companyInfo = companys.get(Integer.valueOf(user.companyId));
  List<Map<String, Object>> taskCategory = companyInfo.taskCategorys;
  List<User> users = companyInfo.users;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>任务</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta name="renderer" content="webkit"/>
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  <link rel="shortcut icon" href="<%=request.getContextPath()%>/images/qikebao.ico" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/all.css?ver=<%=Const.VERSION%>">
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/datepicker.css" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrap-datetimepicker.min.css" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/magnific-popup.css">
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery-1.11.1.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery-ui.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.bootstrap-growl.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/moment.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap-datepicker.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap-datetimepicker.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/daterangepicker.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.magnific-popup.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.cookie.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/popbox.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/common.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/rightTask.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/tasks.js?ver=<%=Const.VERSION%>"></script>
  <script>
    _isShowAllInfo = true;
    params.offset = 0;
    var pageSize = <%=Const.PAGE_SIZE%>;
    var userId = "<%=user.userId%>";
    var allUsers = new Array();
    <%if (users != null) {
        for (User u:users) { %>
    allUsers.push({id:"<%=u.userId%>",name:"<%=Util.UEncode(u.name)%>",photo:"<%=u.imgPath%>"});
    <%  }} %>
  </script>
</head>
<body class="parties">
  <jsp:include page="topNavi.jsp" flush="true"/>
  <div class="main-page">
    <table>
    <tr>
      <td class="main-body">
        <div class="topnavi">
          <div class='leftMenu'>
            <span>任务</span>
          </div>
          <div class="clearfix"></div>
        </div>
        <div class='switchTab'>
          <a href="#" v="0" class="taskstatus on"><i class="fa fa-circle-o-notch"></i> 进行中</a><a href="#" v="1" class="taskstatus finish"><i class="fa fa-check"></i> 已完成</a><!--<a href="#" v="2" class="taskstatus other"><i class="fa fa-users"></i> 分配给同事</a>-->
        </div>
        <div id="tasks_loading" class="loading">
          <div class="liner">
            <h3>任务加载中...</h3>
            <img alt="Dots-white" src="<%=request.getContextPath()%>/images/dots-white.gif" />
          </div>
        </div>
        <div id="tasks_none" class="loading" style="display:none;">
          <div class="liner">
            <h3>没有符合条件的任务</h3>
          </div>
        </div>
        <div class="searchresult" id="searchresult">
          <div class="tasklist overdue" id="overdueTasks">
            <h6> 已过期 </h6>
            <ul class="tasks"></ul>
          </div>
          <div class="tasklist" id="todayTasks">
            <h6> 今天 </h6>
            <ul class="tasks"></ul>
          </div>
          <div class="tasklist" id="tomorrowTasks">
            <h6> 明天 </h6>
            <ul class="tasks"></ul>
          </div>
          <div class="tasklist" id="thisWeekTasks">
            <h6> 本周 </h6>
            <ul class="tasks"></ul>
          </div>
          <div class="tasklist" id="nextWeekTasks">
            <h6> 下周 </h6>
            <ul class="tasks"></ul>
          </div>
          <div class="tasklist" id="laterTasks">
            <h6> 以后 </h6>
            <ul class="tasks"></ul>
          </div>
          <div><a href="#" id="searchmore" class="searchmore"><i class="fa fa-angle-double-down"></i> 查看更多...</a> </div>
        </div>
      </td>
      <td class="main-sidebar">
        <div class="content">
          <h2 class="clearfix">检索</h2>
<% if (user.isAdmin || user.isGroupAdmin) { %>
          <h3>任务负责人</h3>
          <select id="searchTaskResponsibleUser" >
            <option value="">全部任务</option>
            <option value="<%=user.userId%>" selected="selected">我的任务</option>
          <%
            String groupName = null;
            for (User u : users) {
              if (u.userId.equals(user.userId)) {
                continue;
              }
              if (!companyInfo.isGroupAdmin(user, u.groupId)) {
                continue;
              }
              String gn = companyInfo.getGroupName(u);
              if (groupName == null) {
                if (gn != null) {
                  groupName = gn;  %>
            <optgroup label="<%=Util.HTMLEncode(groupName)%>">
          <%
                }
              } else {
                if (!groupName.equals(gn)) {
                  groupName = gn; %>
            </optgroup>
            <optgroup label="<%=Util.HTMLEncode(groupName)%>">
          <%
                }
              }
          %>
            <option value="<%=u.userId%>"><%=Util.HTMLEncode(u.name)%>的任务</option>
          <%}
            if (groupName != null && groupName.length() > 0) { %>
            </optgroup>
          <%}%>
          </select>
<% }%>
          <h3>任务分类</h3>
          <select id="searchTaskCategory">
            <option value="">全部</option>
            <%for (Map<String, Object> cate:taskCategory) { %>
            <option value="<%=cate.get("TaskCategoryId")%>"><%=Util.HTMLEncode((String)cate.get("TaskCategoryName"))%></option>
            <%}%>
          </select>
        </div>
      </td>
    </tr>
    </table>
  </div>

  <div class="movebox" id="updateTask">
    <div class='arrow'></div><div class='arrow-border'></div>
    <form class="task">
      <h3>修改任务</h3>
      <p class="task_body">
        <input id="update_taskId" type="hidden" value="" />
        <input class="autofocus" id="update_taskTitle" size="25" type="text" />
      </p>
      <div>
        <h5>到期时间</h5>
        <p>
          <div class="datetimepicker_container"><input class="autofocus dueDate" id="update_dueDate" size="25" type="text" /></div>
        </p>
        <h5>任务负责人</h5>
        <p>
          <select id="update_responsibleUserId" class="responsibleUserId"></select></p>
        <h5>任务分类</h5>
        <p>
          <select id="update_categoryId" class="categoryId"></select>
          <% if (user.isAdmin) {%>
          <a href="<%=request.getContextPath()%>/taskcategory" class="edit_categories">编辑分类</a>
          <% }%>
        </p>
        <p class="hide">
          <input class="checkbox" id="update_taskVisible" type="checkbox" value="1" />
          <label for="update_taskVisible">所有人可以看见这个任务</label>
        </p>
      </div>
      <div class="submit">
        <a id="update_task_button" class="button blue small closePopbox" href="#"><i class="fa fa-check"></i> 修改任务</a>
        &nbsp;&nbsp;<a href="#" class="closePopbox" id="update_task_cancel_link">取消</a>
      </div>
    </form>
  </div>

</body>
</html>